﻿using Shell32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Client
{
    public class MPlayer
    {
        string path;
        public MPlayer(string  _path)
        {
            path = _path;
        }
        public string getTitle()
        {


            return  getMusicInf(path)[0];
        }
        public string getArtists()
        {

            return  getMusicInf(path)[1];
        }
        public string getAlbum()
        {

            return getMusicInf(path)[2];
        }
        string[] getMusicInf(string path)
        {
            string[] Info = new string[7];
            ShellClass sh = new ShellClass();


            Folder dir = sh.NameSpace(Path.GetDirectoryName(path));
            FolderItem item = dir.ParseName(Path.GetFileName(path));
            Info[0] = dir.GetDetailsOf(item, 21);//歌曲名
            Info[1] = dir.GetDetailsOf(item, 13);//作者
            Info[2] = dir.GetDetailsOf(item, 14);//专辑
            Info[3] = dir.GetDetailsOf(item, 27);//时长
            Info[4] = dir.GetDetailsOf(item, 1);//大小
            return Info;
            /*
			//Info[1] = dir.GetDetailsOf(item, 20);
			Info[6] = dir.GetDetailsOf(item, 13);
			Info[3] = dir.GetDetailsOf(item, 27);
			Info[3] = Info[3].Substring(Info[3].IndexOf(":") + 1);
			Info[4] = dir.GetDetailsOf(item, 1);*/
            /*
			 * ID  => DETAIL-NAME
      0   => Name     //文件名
      1   => Size     //文件大小
      13  => Artists   //艺术家
      14  => Album     //专辑
      15  => Year      //出版年份
      20  => Authors   //同艺术家
      21  => Title     //标题
      26  => #         //编号
      27  => Length    //时长
			 */
        }
        //定义歌曲结构
    }

}
